package com.ruoyi.project.jiaqin.companycarousel.service.impl;

import com.ruoyi.common.utils.text.Convert;
import com.ruoyi.project.jiaqin.companycarousel.domain.CompanyCarousel;
import com.ruoyi.project.jiaqin.companycarousel.mapper.CompanyCarouselMapper;
import com.ruoyi.project.jiaqin.companycarousel.service.ICompanyCarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.UUID;

/**
 * 企业轮播图Service业务层处理
 *
 * @author admin
 * @date 2021-01-08
 */
@Service
public class CompanyCarouselServiceImpl implements ICompanyCarouselService
{
    @Autowired
    private CompanyCarouselMapper companyCarouselMapper;

    /**
     * 查询企业轮播图
     *
     * @param id 企业轮播图ID
     * @return 企业轮播图
     */
    @Override
    public CompanyCarousel selectCompanyCarouselById(String id)
    {
        return companyCarouselMapper.selectCompanyCarouselById(id);
    }

    /**
     * 查询企业轮播图列表
     *
     * @param companyCarousel 企业轮播图
     * @return 企业轮播图
     */
    @Override
    public List<CompanyCarousel> selectCompanyCarouselList(CompanyCarousel companyCarousel)
    {
        return companyCarouselMapper.selectCompanyCarouselList(companyCarousel);
    }

    /**
     * 新增企业轮播图
     *
     * @param companyCarousel 企业轮播图
     * @return 结果
     */
    @Override
    public int insertCompanyCarousel(CompanyCarousel companyCarousel)
    {
        companyCarousel.setId(UUID.randomUUID().toString().replace("-",""));
        companyCarousel.setCreatedTime(new Date());
        return companyCarouselMapper.insertCompanyCarousel(companyCarousel);
    }

    /**
     * 修改企业轮播图
     *
     * @param companyCarousel 企业轮播图
     * @return 结果
     */
    @Override
    public int updateCompanyCarousel(CompanyCarousel companyCarousel)
    {
        return companyCarouselMapper.updateCompanyCarousel(companyCarousel);
    }

    /**
     * 删除企业轮播图对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteCompanyCarouselByIds(String ids)
    {
        return companyCarouselMapper.deleteCompanyCarouselByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除企业轮播图信息
     *
     * @param id 企业轮播图ID
     * @return 结果
     */
    @Override
    public int deleteCompanyCarouselById(String id)
    {
        return companyCarouselMapper.deleteCompanyCarouselById(id);
    }

    @Override
    public CompanyCarousel selectCompanyCarouselByImgId(String imgId) {
        return companyCarouselMapper.selectCompanyCarouselByImgId(imgId);
    }

    @Override
    public int deleteCompanyCarouselByImgId(String imgId) {
        return companyCarouselMapper.deleteCompanyCarouselByImgId(imgId);
    }
}
